---@class D4.skill
local M = {}

---打印当前角色的所有技能信息
function M.PrintAllSkills()
    local SkillList = Game.GetSkillList()
    if not SkillList then return end
    if #SkillList == 0 then return end
    print(string.format("M.SkillID.%s = {", Game.GetPlayerClassName()))
    for _, SkillID in ipairs(SkillList) do
        local SkillName = Game.GetSkillName(SkillID)
        local SkillLevel = Game.GetSkillLevel(SkillID)
        --print(string.format("技能ID: %d, 名称: %s, 等级: %d", SkillID, SkillName, SkillLevel))
        print(string.format("  %s = %d,", SkillName, SkillID))
    end
    print("}")
    --     print(string.format([[[%d] = {
    -- 	name = "%s",
    -- 	priority = 2,
    -- 	condition = function(data)
    -- 		if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
    -- 			return true
    -- 		end
    -- 		return false
    -- 	end,
    -- },]], SkillID, Game.GetSkillName(SkillID)))
    --print(_ .. " 使用技能:" .. SkillID .. " 名字:" .. Game.GetSkillName(SkillID))
end

---@class SkillInfo
---@field name string 技能名称
---@field priority integer? 技能优先级，数值越大优先级越高，默认为0
---@field condition fun(data:any):boolean 释放条件函数
M.data = {
    ["通用"] = {
        [0x52487] = {
            name = "闪避",
            condition = function(data)
                return 0
            end,
        },
    },
    ["Spiritborn"] = {
        [1817045] = {
            name = "Spiritborn_Gorilla_Basic",
            name_cn = "碎岩重击",
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1834476] = {
            name = "Spiritborn_Eagle_Basic",
            name_cn = "雷霆尖刺",
            condition = function(data)
                local bo = -1
                Tool.TriggerInterval(4, 0.2, function()
                    if data.Distance > 5 then
                        Game.UseSkill(0x52487, -1, data.Location, true)
                        bo = -1
                        return
                    end
                    bo = 1
                end)
                return bo
            end,
        },
        [1834473] = {
            name = "Spiritborn_Jaguar_Basic",
            name_cn = "痛击",
            condition = function(data)
                local bo = -1
                Tool.TriggerInterval(3, 0.1, function()
                    if data.Distance > 5 then
                        Game.UseSkill(0x52487, -1, data.Location, true)
                        bo = -1
                        return
                    end
                    bo = 1
                end)
                return bo
            end,
        },
        [1834471] = {
            name = "Spiritborn_Centipede_Basic",
            name_cn = "枯萎重拳",
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1519050] = {
            name = "Spiritborn_Gorilla_Core",
            name_cn = "碾压之拳",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1519048] = {
            name = "Spiritborn_Eagle_Core",
            name_cn = "翎羽箭幕",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1640931] = {
            name = "Spiritborn_Jaguar_Core",
            name_cn = "耙击",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1836008] = {
            name = "Spiritborn_Centipede_Core",
            name_cn = "蛰刺",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1489641] = {
            name = "Spiritborn_Eagle_Focus",
            name_cn = "旋涡",
            priority = 3,
            condition = function(data)
                local count = 0
                for _, unit in ipairs(data.Array) do
                    if unit.Distance < 6 then
                        count = count + 1
                    end
                end
                if Game.GetSkillState(data.ID) == 0 and count > 4 then
                    return 1
                end
                return -1
            end,
        },
        [1871821] = {
            name = "Spiritborn_Eagle_Focus2",
            name_cn = "飞空",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1862773] = {
            name = "Spiritborn_Jaguar_Focus",
            name_cn = "劫掠者",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871813] = {
            name = "Spiritborn_Centipede_Focus",
            name_cn = "毒素之肤",
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871764] = {
            name = "Spiritborn_Gorilla_Defensive1",
            name_cn = "披甲厚皮",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871825] = {
            name = "Spiritborn_Gorilla_Defensive2",
            name_cn = "震荡践踏",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871819] = {
            name = "Spiritborn_Jaguar_Defensive",
            name_cn = "反击",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871801] = {
            name = "Spiritborn_Centipede_Defensive",
            name_cn = "灾虫",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871823] = {
            name = "Spiritborn_Gorilla_Potency",
            name_cn = "报复",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871807] = {
            name = "Spiritborn_Eagle_Potency1",
            name_cn = "剃刀飞鹰",
            priority = 1,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871761] = {
            name = "Spiritborn_Jaguar_Potency",
            name_cn = "急促爪击",
            priority = 1,
            condition = function(data)
                --print("技能ID:" .. data.ID .. " GetSkillState:" .. Game.GetSkillState(data.ID))
                if Game.GetSkillState(data.ID) == 256 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1871809] = {
            name = "Spiritborn_Centipede_Potency",
            name_cn = "死亡之触",
            priority = 1,
            condition = function(data)
                --print("技能ID:" .. data.ID .. " GetSkillState:" .. Game.GetSkillState(data.ID))
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1663208] = {
            name = "Spiritborn_Gorilla_Ultimate",
            name_cn = "保护者",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1663204] = {
            name = "Spiritborn_Eagle_Ultimate",
            name_cn = "寻迹者",
            priority = 2,
            condition = function(data)
                local count = 0
                for _, unit in ipairs(data.Array) do
                    if unit.Distance < 6 then
                        count = count + 1
                    end
                end
                if Game.GetSkillState(data.ID) == 0 and Game.GetSkillState(1489641) > 0 and count > 4 then
                    return 1
                end
                return -1
            end,
        },
        [1663206] = {
            name = "Spiritborn_Jaguar_Ultimate",
            name_cn = "追猎者",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 3 and #data.Array > 3 then
                    return 1
                end
                return -1
            end,
        },
        [1663210] = {
            name = "Spiritborn_Centipede_Ultimate",
            name_cn = "吞噬者",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        }
    },
    ["德鲁伊"] = {
        [543387] = {
            name = "Druid_Earthspike_Instant",
            priority = 0,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [313893] = {
            name = "Druid_landslide",
            priority = 0,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [272138] = {
            name = "Druid_Pulverize",
            priority = 0,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [333421] = {
            name = "Druid_EarthenBulwark",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [336238] = {
            name = "Druid_DebilitatingRoar",
            priority = 3,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 10 then
                    return 0
                end
                return -1
            end,
        },
        [439581] = {
            name = "Druid_Claw",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [309320] = {
            name = "Druid_StormStrike",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [304065] = {
            name = "Druid_Tornado",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [548399] = {
            name = "Druid_LightningStorm",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [258243] = {
            name = "Druid_Trample",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [258990] = {
            name = "Druid_Hurricane",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [356587] = {
            name = "Druid_WindShear",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [238345] = {
            name = "Druid_Boulder",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [309070] = {
            name = "Druid_Maul",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [281516] = {
            name = "Druid_Ravens",
            name_cn = "渡鸦",
            priority = 0,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 10 then
                    return 1
                end
                return -1
            end,
        },
        [314601] = {
            name = "Druid_VineCreeper",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [265663] = {
            name = "Druid_WolfPack",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [280119] = {
            name = "Druid_CycloneArmor",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 10 then
                    return 1
                end
                return -1
            end,
        },
        [566517] = {
            name = "Druid_BloodHowl",
            priority = 5,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 10 then
                    return 0
                end
                return -1
            end,
        },
        [416337] = {
            name = "Druid_Rabies",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [266570] = {
            name = "Druid_Cataclysm",
            name_cn = "浩劫",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 10 then
                    return 0
                end
                return -1
            end,
        },
        [267021] = {
            name = "Druid_GrizzlyRage",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [394251] = {
            name = "Druid_Lacerate",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [351722] = {
            name = "Druid_Petrify",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1256958] = {
            name = "Druid_Shred_NEW",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
        [1473878] = {
            name = "Druid_StoneBurst",
            priority = 2,
            condition = function(data)
                if Game.GetSkillState(data.ID) == 0 and data.Distance < 5 then
                    return 1
                end
                return -1
            end,
        },
    }
}

return M
